var oa = document.getElementById('totop');
//在500ms之内，移动到顶端，每10ms向上移动140px,一共移动50次。

var num = 0;
var timer = null;
 function move(){
    const instance = document.documentElement.scrollTop/50;
     window.clearTimeout(timer);
    
    console.log(instance);
    num++;
    if(num == 10){
        return;
    }
     timer = setInterval(function(){
        document.documentElement.scrollTop = document.documentElement.scrollTop - instance;
        if(document.documentElement.scrollTop == 0){
            window.clearInterval(timer);
            
        }
    },10);
    
    
    
    
    
    
    
    
}
oa.addEventListener('click',move);

